<!--
 * @Descripttion: 
 * @version: 
 * @Author: fmy1993
 * @Date: 2021-09-20 21:43:30
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-09-27 10:43:49
-->
<template>
  <div class="app-container">
    <!-- 直接传入一个数组 -->
    <!-- <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="加载中"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="区块高度" width="95" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.blockheight }}</span>
        </template>
      </el-table-column>
      <el-table-column label="当前区块hash">
        <template slot-scope="scope">
          {{ scope.row.currentblockinfo }}
        </template>
      </el-table-column>
      <el-table-column label="前区块hash" width="510" align="center">
        <template slot-scope="scope">
          {{ scope.row.previousblockinfo }}
        </template>
      </el-table-column>
  
    </el-table> -->

    

    <el-table
      v-loading="listLoading"
      :data="resplist"
      element-loading-text="加载中"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="UUID" width="310" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="数据类型">
        <template slot-scope="scope">
          {{ scope.row.datatype }}
        </template>
      </el-table-column>
      <el-table-column label="hash值" width="510" align="center">
        <template slot-scope="scope">
          {{ scope.row.hashinfo}}
        </template>
      </el-table-column>

    </el-table>

  </div>
</template>

<script>
// 解构只导入对应的方法
import { getBCList,getLedgerList } from "@/api/tablebc";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger",
      };
      return statusMap[status];
    },
  },
  data() {
    return {
      // model 绑定的内容
      list: null,
      resplist:null,
      // 控制加载方法的调用
      listLoading: true,
    };
  },
  created() {
    // 组件初始化时就直接调用
    // this.fetchData();
    this.fetchTableData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      // 调用引入的方法
      getBCList().then((response) => {
        let tableArray = new Array();
        tableArray.push(response.data);
        // this.list = response.data.items
        this.list = tableArray;

        // console.log(this.list)
        this.listLoading = false;
      });
    },
    fetchTableData(){
      this.listLoading = true;
            // init request json 
      let keyArray = new Array();
      let resquestObj = {
        args: keyArray
      };
      console.log(resquestObj);
      getLedgerList(resquestObj).then((response) => {
       this.resplist = Array.from(response.data)
      });
      this.listLoading = false;
    }
  },
};
</script>
